﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NHibernate;
using NHibernate.Linq;
using dbPoll_Application.Helpers;
using NHibernate.Criterion;

namespace dbPoll_Application.Models
{
    public class FieldsTemplateRepository
    {
        public static IList<FieldsTemplate> GetFieldsTemplates()
        {
            ISession session = NHibernateHelper.GetCurrentSession();
            var templates = (from item in session.Query<FieldsTemplate>()
                             select item).ToList<FieldsTemplate>();
            return templates;
        }

        public static FieldsTemplate GetTemplateByTemplateID(int templateID)
        {
            ISession session = NHibernateHelper.GetCurrentSession();
            var templates = (from item in session.Query<FieldsTemplate>()
                             where item.templateID == templateID
                             select item).FirstOrDefault<FieldsTemplate>();
            return templates;
        }
    }
}
